package IC.AST;


import IC.SymbolTable.* ;

/**
 * Abstract AST node base class.
 * 
 * @author Tovi Almozlino
 */
public abstract class ASTNode {

	private int line;
	
	/** reference to symbol table of enclosing scope **/
	private SymbolTable enclosingScope;
	

	/**
	 * Double dispatch method, to allow a visitor to visit a specific subclass.
	 * 
	 * @param visitor
	 *            The visitor.
	 * @return A value propagated by the visitor.
	 */
	public abstract Object accept(Visitor visitor)throws SemanticError;

	
	/** accept propagating visitor **/
	public abstract <D,U> U accept(PropagatingVisitor<D,U> v,D context)throws Exception;

	
	
	/**
	 * Constructs an AST node corresponding to a line number in the original
	 * code. Used by subclasses.
	 * 
	 * @param line
	 *            The line number.
	 */
	protected ASTNode(int line) {
		this.line = line;
	}

	/** return line number of this AST node in program **/
	public int getLine() {
		return line;
	}
	
	/** set symbol table of enclosing scope **/
	public void setEnclosingScope(SymbolTable enc){
		this.enclosingScope = enc;
	}
	
	/** returns symbol table of enclosing scope **/
	public SymbolTable getEnclosingScope(){
		return this.enclosingScope;
	}
	

}
